home *** CD-ROM | disk | FTP | other *** search
-
- /**
- * Functions for get\set cookie
- */
- const DoGoodCookie =
- {
- /**
- * Function for check ignoring sites.
- *
- * @param {object} doc - current loaded document
- * @param {string} link - link of site
- */
- isIgnore : function(link, doc) {
- if (link == "about:blank") return true;
- if (DoGoodFilter.RegExpWhiteList(link)) return true;
- if (DoGoodCookie.readCookie('dogoodIgnore', doc) == 1) return true;
- if (DoGoodCookie.readCookie('DoGoodShowAll', doc) == 'yes') return true;
-
- return false;
- },
-
- /**
- * Function for create cookie.
- *
- * @param {string} name - name of variable
- * @param {string} value - value of variable
- * @param {int} link - count days for saving
- */
- createCookie : function(name, value, days) {
- var doc = window.content.document;
- if (days) {
- var date = new Date();
- date.setTime(date.getTime()+(days*24*60*60*1000));
- var expires = "; expires="+date.toGMTString();
- }
- else var expires = "";
- doc.cookie = name+"="+value+expires+"; path=/";
- },
-
- /**
- * Function for read cookie.
- *
- * @param {string} name - name of variable
- * @param {object} doc - current loaded document
- */
- readCookie : function(name, doc) {
- if (!doc) doc = window.content.document;
- var nameEQ = name + "=";
- var ca = doc.cookie || null;
- if (ca) {
- ca = ca.split(';');
- for(var i=0;i < ca.length;i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1,c.length);
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
- }
- }
- return null;
- }
- };